<h1><%= t 'views.chunk.index.title' %></h1>

<table>
  <tr>
    <th><%= Chunk.human_attribute_name(:title) %></th>
    <th><%= Chunk.human_attribute_name(:section) %></th>
    <th><%= Chunk.human_attribute_name(:user) %></th>
    <th><%= Chunk.human_attribute_name(:version) %></th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @chunks.each do |chunk| %>
  <tr>
    <td><%= chunk.title %></td>
    <td><%= chunk.section %></td>
    <td><%= chunk.username %></td>
    <td><%= chunk.versions.last.id unless chunk.versions == nil%></td>
    <td><%= link_to I18n.t('views.show'), book_chunk_path(@book, chunk) %></td>
    <td><%= link_to I18n.t('views.edit'), edit_book_chunk_path(@book, chunk) %></td>
    <td><%= link_to I18n.t('views.delete'), book_chunk_path(@book, chunk), method: :delete, data: { confirm: I18n.t('views.are_you_sure') } %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to I18n.t('views.chunk.index.new'), new_book_chunk_path(@book) %>
